package com.boliq.demo;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import com.boliq.demo.adapter.MainVpAdapter;

public class FragmentActivity extends AppCompatActivity {

//    private DemoFragment topFragment;
//    private DemoFragment bottomFragment;

    private ViewPager mVp;
    private TextView homeView;
    private TextView newsView;
    private TextView mineView;

    private MainVpAdapter mainVpAdapter;
    //几个代表页面的常量
    public static final int PAGE_ONE = 0;
    public static final int PAGE_TWO = 1;
    public static final int PAGE_THREE = 2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);
        mVp = findViewById(R.id.vp_content);
        homeView = findViewById(R.id.tv_main_btn);
        newsView = findViewById(R.id.tv_news_btn);
        mineView = findViewById(R.id.tv_mine);



        mainVpAdapter = new MainVpAdapter(getSupportFragmentManager());
        mVp.setAdapter(mainVpAdapter);


        homeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mVp.setCurrentItem(0);
            }
        });

        newsView.setOnClickListener(view -> mVp.setCurrentItem(1));

        mineView.setOnClickListener(view -> mVp.setCurrentItem(2));
    }


    @Override
    protected void onStart() {
        super.onStart();
        Log.e("tag","onStart");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.e("tag","onRestart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e("tag","onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("tag","onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("tag","onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("tag","onDestroy");
    }
}
